<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=0">
  <title>Document</title>
  <script src="./js/ezuikit.js"></script>
  <style>
    html,body {
      padding: 0;
      margin: 0;
      text-align: center;
      background: #000;
      overflow: hidden;
      width: 100%;
      height: 100%;
    }
    #playWind {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
    }
  </style>
</head>

<body>
<div id="playWind"></div>
<script>
  let domain = "/";
  function getQueryString(name, url) {
    var r = new RegExp("(\\?|#|&)" + name + "=(.*?)(#|&|$)");
    var m = (url || window.location.href).match(r);
    return decodeURIComponent(m ? m[2] : '');
  };


  let EZOPENDemo;

  const width = document.documentElement.clientWidth;
  const height = document.documentElement.clientWidth * 9 / 16;

  const title = getQueryString("title")
  document.title = title || '直播'

  const ezopenInit = (accessToken, url) => {
    EZOPENDemo = new EZUIKit.EZUIKitPlayer({
      id: 'playWind',
      width: width,
      height: height,
      template: "standard",
      staticPath: "/console/ezuikit_static/v6",
      url: url,
      accessToken: accessToken
    });

    window.EZOPENDemo = EZOPENDemo;
  }


  let urlEz = decodeURIComponent(getQueryString("url"));
  if (decodeURIComponent(getQueryString("end"))) {
    urlEz = decodeURIComponent(getQueryString("url")) + '&end=' + decodeURIComponent(getQueryString("end"))
  }

  const queryData = {
    appKey: getQueryString('appKey'),
    appSecret: getQueryString('appSecret'),
  }
  fetch('https://open.ys7.com/api/lapp/token/get?appKey=' + queryData.appKey + '&appSecret=' + queryData.appSecret, {
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  }).then((response) => response.json()).then((res) => {
    const accessToken = res.data.accessToken
    ezopenInit(accessToken, urlEz)
  })
</script>
</body>

</html>
